package model.entity;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import model.entity.product.Product;

@Entity
@Table(name = "SalesDetails")
public class SalesDetails {

	private SalesDetailsId id;
	private Product product;
	private Sales sales;
	private double promotionPercent;

	public SalesDetails() {
	}

	public SalesDetails(SalesDetailsId id, Product product, Sales sales,
			double promotionPercent) {
		this.id = id;
		this.product = product;
		this.sales = sales;
		this.promotionPercent = promotionPercent;
	}

	@EmbeddedId
	@AttributeOverrides({
			@AttributeOverride(name = "salesId", column = @Column(name = "SalesID", nullable = false)),
			@AttributeOverride(name = "productId", column = @Column(name = "ProductID", nullable = false)) })
	public SalesDetailsId getId() {
		return this.id;
	}

	public void setId(SalesDetailsId id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ProductID", nullable = false, insertable = false, updatable = false)
	public Product getProduct() {
		return this.product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "SalesID", nullable = false, insertable = false, updatable = false)
	public Sales getSales() {
		return this.sales;
	}

	public void setSales(Sales sales) {
		this.sales = sales;
	}

	@Column(name = "PromotionPercent", nullable = false, precision = 53, scale = 0)
	public double getPromotionPercent() {
		return this.promotionPercent;
	}

	public void setPromotionPercent(double promotionPercent) {
		this.promotionPercent = promotionPercent;
	}

}
